#ifndef CONV2D_H
#define CONV2D_H
#include "module.h"
#include "tensor.h"

class Conv2d:public Module{
    public:
        Conv2d(int in_channel, int out_channel, int kernel_size, int padding, int stride, int device, int require_grad);
        int in_channel;
        int out_channel;
        int kernel_size;
        int padding;
        int stride;   
        Tensor *weight;
        Tensor *input;
        Tensor *weight_grad; 
        Tensor *grad_at; 
        Tensor *forward(Tensor *x) override;
        void backward(Tensor *grad) override;
        void update(float lr) override;
        void mFree() override;
};

Tensor *fun_padding(Tensor *x, int pad); 
Tensor *fun_conv2d(Tensor *x, int in_channel,int out_channel, Tensor *kernel, int stride, int padding);
Tensor *conv2d_backwordw(Tensor *grad, Tensor *input, int in_channel, int out_channel, int stride, int padding);
Tensor *conv2d_backwordat(Tensor *grad, Tensor *kernel, int in_channel, int out_channel, int stride, int padding);

#endif // CONV2D_H